﻿@using ForzaGT3.Data
@model IEnumerable<News>
@{
    int dataIndex = 0;
    string lang = string.Empty;
    if (!string.IsNullOrEmpty(Request.QueryString["lang"]))
    {
        lang = Request.QueryString["lang"];
    }   
}
<div class="greybg header shadow">
    LATEST NEWS <span class="more">
    @if (!string.IsNullOrEmpty(lang) && lang == "en")
    {
        <a href="@Url.Action("Index", "News", new { lang = lang })">More</a>
    }
    else
    {
        <a href="@Url.Action(MVC.News.Index())">More</a>
    }
    </span>
</div>
@if (Model != null)
{
    foreach (News news in Model)
    {
        if (dataIndex == 0)
        {
    <div class="newscontent blackbg" style="height:157px;">
        <img src="@Url.Content("~" + news.ImageUrl)" align="left" style="margin-right: 10px; width:111px" alt="@news.ImageText" />
        @news.CreatedDate.ToString("dd MMMM yyyy")
        <hr />
        <div class="yellowtext">
            @if (lang == "en")
            {
                @MvcHtmlString.Create(news.NewsTitleEng)
            }
            else
            {
                @MvcHtmlString.Create(news.NewsTitle)
            }
        </div>
        @if (lang == "en")
        {
            if (!string.IsNullOrEmpty(news.NewsIntroEng) && news.NewsIntroEng.Length > 150)
            {
                @MvcHtmlString.Create(news.NewsIntroEng.Substring(0, 150))
            }
            else
            {
                @MvcHtmlString.Create(news.NewsIntroEng)
            }
        }
        else
        {
            if (!string.IsNullOrEmpty(news.NewsIntro) && news.NewsIntro.Length > 150)
            {
                @MvcHtmlString.Create(news.NewsIntro.Substring(0, 150))
            }
            else
            {
                @MvcHtmlString.Create(news.NewsIntro)
            }
        }
        <a href="@Url.Action("Details", "News", new { Id = news.NewsUrl, lang = lang })">read more</a>
    </div>
        }
        else
        {
    <div class="newscontent greybgtxt widget">
        @news.CreatedDate.ToString("dd MMMM yyyy")
        <hr />
        <div class="yellowtext">
        @if (lang == "en")
        {
            @MvcHtmlString.Create(news.NewsTitleEng)
        }
        else
        {
            @MvcHtmlString.Create(news.NewsTitle)
        }
        </div>
        <a href="@Url.Action("Details", "News", new { Id = news.NewsUrl, lang = lang })">read more</a>
    </div>
           
        }

        dataIndex += 1;
    }

}